//
//  TYAddLifeProps.m
//  AngerDragon
//
//  Created by gaotime_macbook_2 on 11-12-6.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TYAddLifeProps.h"
#import "TYPlayerCommunicateProtocol.h"
#import "TYPlayer.h"

@implementation TYAddLifeProps
 
- (id) init {
	
	if ((self = [super init]))
	{
		CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
		
		/// 初始化道具的状态
		//m_n_state = kPropsStates_Live;
		
		 
	}
	
	return self;
}

- (void) dealloc {
	CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
	
	[super dealloc];
}

#pragma mark 实现动作库接口
- (void) initActionSequence {
	/*
	NSMutableArray* bfarray = [CCArray array];
	for (int i=0; i<4; i++) {
		[bfarray addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
												spriteFrameByName:[NSString stringWithFormat:@"knight_0_walk_%d.png",i]]];
	}
	CCAnimation* bfani = [CCAnimation animationWithFrames:bfarray delay:0.2f];
	CCAction* walkAction = [CCRepeatForever actionWithAction:
													[CCAnimate actionWithAnimation:bfani restoreOriginalFrame:NO]];
	
	CCMoveTo* actionMove = [CCMoveTo actionWithDuration:pathLength/speed position:CGPointMake(240,60)];
	CCSequence* sequence1 = [CCSequence actions:walkAction, actionMove,   nil];
	[self.m_p_action_warehouse_array addObject:sequence1];
	
	actionArray = [[NSMutableArray alloc] init];
	[actionArray addObject:walkAction];
	
	NSMutableArray* bfarrayHit = [NSMutableArray array];
	for (int i=0; i<4; i++) {
		[bfarrayHit addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
													 spriteFrameByName:[NSString stringWithFormat:@"knight_0_hit_%d.png",i]]];
	}
	CCAnimation* bfaniHit = [CCAnimation animationWithFrames:bfarrayHit delay:0.2f];
	CCAction* hitAction = [CCRepeatForever actionWithAction:
												 [CCAnimate actionWithAnimation:bfaniHit restoreOriginalFrame:NO]];
	[actionArray addObject:hitAction];
	
	NSMutableArray* arrayRun = [NSMutableArray array];
	for (int i=0; i<4; i++) {
		[arrayRun addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
												 spriteFrameByName:[NSString stringWithFormat:@"knight_0_running_%d.png",i]]];
	}
	CCAnimation* aniRun = [CCAnimation animationWithFrames:arrayRun delay:0.2f];
	CCAction* actionRun = [CCRepeatForever actionWithAction:
												 [CCAnimate actionWithAnimation:aniRun restoreOriginalFrame:NO]];
	[actionArray addObject:actionRun];
	
	NSMutableArray* arrayRunBurn = [NSMutableArray array];
	for (int i=0; i<3; i++) {
		[arrayRunBurn addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
                             spriteFrameByName:[NSString stringWithFormat:@"knight_0_running_burn_%d.png",i]]];
	}
	CCAnimation* aniRunBurn = [CCAnimation animationWithFrames:arrayRunBurn delay:0.2f];
	CCAction* actionRunBurn = [CCRepeatForever actionWithAction:
														 [CCAnimate actionWithAnimation:aniRunBurn restoreOriginalFrame:NO]];
	[actionArray addObject:actionRunBurn];
	
	NSMutableArray* arrayFight = [NSMutableArray array];
	for (int i=0; i<2; i++) {
		[arrayFight addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
													 spriteFrameByName:[NSString stringWithFormat:@"knight_0_fight_%d.png",i]]];
	}
	CCAnimation* aniFight = [CCAnimation animationWithFrames:arrayFight delay:0.2f];
	CCAction* actionFight = [CCRepeatForever actionWithAction:
													 [CCAnimate actionWithAnimation:aniFight restoreOriginalFrame:NO]];
	[actionArray addObject:actionFight];
	
	NSMutableArray* arrayBurn = [NSMutableArray array];
	for (int i=0; i<3; i++) {
		[arrayBurn addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] 
													spriteFrameByName:[NSString stringWithFormat:@"knight_0_burn_%d.png",i]]];
	}
	CCAnimation* aniBurn = [CCAnimation animationWithFrames:arrayBurn delay:0.2f];
	CCAction* burnAction = [CCRepeatForever actionWithAction:
													[CCAnimate actionWithAnimation:aniBurn restoreOriginalFrame:NO]];
	[actionArray addObject:burnAction];	 
	 */
}

#pragma mark 实现精灵AI接口
- (void) ai:(ccTime)delta {
	
}

#pragma mark 实现使用道具接口
- (void) useThisProp {
	/// 此道具的效果
	//id<TYPlayerCommunicateProtocol> a_player = [TYPlayer sharedPlayer];
//	[a_player addLifeValue:0];
	
	/// 更改当前道具的状态
//	m_n_state = kPropsStates_Used;
}


@end
